#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    int res = 0;
    string s = "123456789";
    do {
        for (int i = 1; i <= 7; ++i) {
            string s1 = s.substr(0, i);
            int a1 = atoi(s1.c_str());
            if (a1 && a1 <= n) {
                for (int j = 1; j <= 9 - i; ++j) {
                    string s2 = s.substr(i, j);
                    int a2 = atoi(s2.c_str());
                    string s3 = s.substr(i + j, 10 - i - j);
                    int a3 = atoi(s3.c_str());
                    if (a2 && a3 && a1 + a2 * 1.0 / a3 == n) res++;
                }
            }
        }
    } while (next_permutation(s.begin(), s.end()));
    cout << res << endl;
    return 0;
}